package com.ofhb.bean;

import java.util.List;

import javax.ejb.LocalBean;
import javax.ejb.Singleton;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.ofhb.entities.CityEntity;

/**
 * Session Bean implementation class LookUpBean
 */
@Singleton(name = "LookUpBean", mappedName = "ejb/LookUpBean")
@LocalBean
public class LookUpBean implements LookUpBeanRemote {

	private List<CityEntity> listCityEntities = null;

	 @PersistenceContext(name = "my_persistence_ctx")
	 EntityManager em;
		
	 
	/**
	 * Default constructor.
	 */
	public LookUpBean() {
		// TODO Auto-generated constructor stub
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<CityEntity> getAllCityEntities() {
		if (listCityEntities == null) {
			listCityEntities =(List<CityEntity>)em.createQuery("SELECT e FROM CityEntity e").getResultList();
		}
		return listCityEntities;
	}

}
